<%-- 
    Document   : orderreview
    Created on : Jan 26, 2013, 6:41:25 PM
    Author     : KAKAIT
--%>
<%@page import="model.entity.Account"%>
<%@page import="model.entity.Product"%>
<%@page import="java.util.List"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<div class="col-main" id="ves-col-main">
						<!-- main content -->
    <div class="page-title">
        <h1>Checkout</h1>
    </div>
<%
     List<Product> lprocart = (List<Product>)session.getAttribute("shoppingcart");
     Account acc = (Account)session.getAttribute("acc");
     double grand_Total = 0;  
%>
    <ol id="checkoutSteps" class="opc">
   
       <li class="section allow active" id="opc-review">
            <div class="step-title">
                <h2>Order Review</h2>
            </div>
           <%
           String messages = (String)request.getAttribute("message");
            if(messages!=null)
                                              {%>
               <ul class="messages"><li class="error-msg"><ul><li><span><%= messages%></span></li></ul></li></ul>                     <%}
            %>  
            <div style="" class="step a-item" id="checkout-step-review">
                <div id="checkout-review-load" class="order-review">    
                    <div id="checkout-review-table-wrapper">
                        <table id="checkout-review-table" class="data-table">
                            <colgroup>
                            <col width="1">
                            <col>
                            <col width="1">
                            <col width="1">
                            <col width="1">
                            </colgroup>
                            <thead>
                                <tr class="first last">
                                    <th rowspan="1">Product Image</th>
                                    <th class="a-center" colspan="1">Product Name</th>
                                    <th class="a-center" colspan="1">Price</th>
                                    <th class="a-center" rowspan="1">Qty</th>
                                    <th class="a-center" colspan="1">Subtotal</th>
                                </tr>
                            </thead>
                            
                            <tbody>
                        <%
                                double money = 0;
                                for(int i = 0; i < lprocart.size();i++)
                                {
                                    money = lprocart.get(i).getTotalamount() * lprocart.get(i).getQuantity();

                                    grand_Total += money;
                          %>
                                <tr class="">
                                    <td><a class="product-image" title="<%= lprocart.get(i).getProductname() %>" href="#"><img width="150" height="150" alt="" src="images/product/<%= lprocart.get(i).getPicture().toString() %>"></a>
                                    </td>
                                    <td class="sct-name">
                                        <h3 class="product-name"><a href="#"><%= lprocart.get(i).getProductname() %></a></h3>
                                    </td>
                                    
                                    <td class="a-right">
                                            <span class="cart-price"><span class="price">$<%= lprocart.get(i).getTotalamount() %></span></span>
                                    </td>
                                    <td class="a-center sct-quantity">
                                        <span class="cart-price"><span class="price"><%= lprocart.get(i).getQuantity() %></span></span>
                                    </td>
                                    <td class="a-right sct-price">
                                        <span class="cart-price"><span class="price">$<%= Double.toString(money) %></span></span>
                                    </td>
                                </tr>
                                
                         <% } %>       
                            </tbody>
                            <tfoot>
                                <tr class="first">
                                    <td colspan="4" class="a-right" style="">
                                        Subtotal    </td>
                                    <td class="a-right last" style="">
                                        <span class="price">$<%= Double.toString(grand_Total) %></span>    </td>
                                </tr>
                                <tr>
                                    <td colspan="4" class="a-right" style="">
                                        Shipping &amp; Handling (Shipping Costs)    </td>
                                    <td class="a-right last" style="">
                                        <%
                                        double d = 0;
                                           if(lprocart.size()<4)
                                               d = 10;
                                           else if(lprocart.size()>=4 && lprocart.size()<8)
                                               d = 20;
                                           else if(lprocart.size()>=8)    
                                               d = 50;
                                              
                                        %>
                                        <span class="price">$<%= d %></span>    
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="4" class="a-right" style="">
                                        <strong>Grand Total</strong>
                                    </td>
                                    <td class="a-right last" style="">
                                        <strong><span class="price">$<%= Double.toString(grand_Total + d) %></span></strong>
                                    </td>
                                </tr>
                                <tr class="last">
                                    <td colspan="4" class="a-right" style="">
                                        <strong>Amount of the current your</strong>
                                    </td>
                                    <td class="a-right last" style="">
                                        <strong><span class="price">$<%= Double.toString(acc.getCredit()) %></span></strong>
                                    </td>
                                </tr>
                                
                            </tfoot>
                        </table>
                        <script type="text/javascript">
                            decorateTable('checkout-review-table', ['odd', 'even', 'first', 'last']);
                            window.document.title ="Order Review";
                            
                        </script>
                    </div>
                    
                    <div id="checkout-review-submit">

                        <div id="review-buttons-container" class="buttons-set">
                            <p class="f-left">Forgot an Item? <a href="<c:url value="/shoppingcart"/>">Edit Your Cart</a></p>
                            <button onclick="window.location='<c:url value="/placeorder"><c:param name="username" value="<%= acc.getUsername()%>"/><c:param name="credit" value="<%= String.valueOf(acc.getCredit()) %>"/><c:param name="totalamount" value="<%= String.valueOf(grand_Total + d) %>"/></c:url>'" class="button btn-checkout" title="Place Order" type="submit"><span><span>Place Order</span></span></button>
                        </div>
                    </div>
                </div>
            </div>
        </li>
    
    </ol>
</div>
